package wei.xinya.pattern.creational.factory.SimpleFactory;

import wei.xinya.pattern.creational.factory.shape.Circle;
import wei.xinya.pattern.creational.factory.shape.Rectangle;
import wei.xinya.pattern.creational.factory.shape.Shape;
import wei.xinya.pattern.creational.factory.shape.Square;

public class Test {
    public static void main(String[] args) {
        // 获取 Circle 的对象，并调用它的 draw 方法
        Shape circle = ShapeFactory.getShape("CIRCLE");
        circle.draw();

        // 获取 Rectangle 的对象，并调用它的 draw 方法
        Shape rectangle = ShapeFactory.getShape("RECTANGLE");
        rectangle.draw();

        // 获取 Square 的对象，并调用它的 draw 方法
        Shape square = ShapeFactory.getShape("SQUARE");
        square.draw();

        circle = (Circle) ShapeFactory.getClass(Circle.class);
        circle.draw();

        rectangle = (Rectangle) ShapeFactory.getClass(Rectangle.class);
        rectangle.draw();

        square = (Square) ShapeFactory.getClass(Square.class);
        square.draw();
    }
}
